import React, { Component } from 'react';
import {
    StyleSheet,
    Text,
    View,
    Image,
    TextInput,
    TouchableOpacity,
    DeviceEventEmitter,
    TouchableWithoutFeedback,
    Modal,
    ScrollView
} from 'react-native';

import { AlertDialog, SimpleItemsBottom } from 'react-native-pickers'
import ImagePicker from 'react-native-image-picker'
import { AudioRecorder, AudioUtils } from 'react-native-audio'
import Sound from 'react-native-sound'

import Constant from '../Constant/Constant'
import ScreenUtils from '../Utils/ScreenUtils'
import ColorUtils from '../Utils/ColorUtils'
import ToastUtils from '../Utils/ToastUtils'
import HttpUtils from '../Utils/HttpUtils'
import RuleUtils from '../Utils/RuleUtils'
import EncryptUtils from '../Utils/EncryptUtils'
import RouterUtils from '../Utils/RouterUtils'
import StorageUtils from '../Utils/StorageUtils'
import TimeUtils from '../Utils/TimeUtils'

const options = {
    title: '请选择',
    cancelButtonTitle: '取消',
    takePhotoButtonTitle: '拍照',
    chooseFromLibraryButtonTitle: '选择相册',
    quality: 0.75,
    allowsEditing: false,
    noData: false,
    storageOptions: {
        skipBackup: true,
        path: 'images',
    },
}

export default class PageXchsHandle extends React.Component
{
    static navigationOptions = ({navigation}) => ({
        gesturesEnabled: false,//是否支持滑动返回收拾，iOS默认支持，安卓默认关闭
        headerTitle: '现场核实',
        headerStyle: {
            backgroundColor: ColorUtils.blue,
            height: ScreenUtils.statusBarHeight,
        },
        headerRight: (<Text></Text>),
        headerTintColor: ColorUtils.white,
        headerTitleStyle: {
            fontSize: ScreenUtils.Font_18,
            color: ColorUtils.white,
            fontWeight: 'normal',
            flex: 1,
            alignSelf: 'center',
            textAlign: 'center',
        }
    });

    constructor(props)
    {
        super(props);
        this.state = {
            result: '请选择核实结果',
            caseDetail: this.props.navigation.state.params.caseDetail,
            geoLocation: '',
            geoAddress: '请选择打卡位置',
            uploadPics: [],
            questionDesc: '',
            longPressDelPicModal: false,
            longPressDelPicItem: {},
            voiceName: '请录音(非必填)',
            voiceUrl: '',
            hasPermission: undefined, //授权状态
            audioPath: AudioUtils.DocumentDirectoryPath + '/test.mp3', // 文件路径
            recording: false, //是否录音
            pause: false, //录音是否暂停
            stop: false, //录音是否停止
            currentTime: '0',
            voiceInputModal: false,
            longPressDelVoiceModal: false,
        };
    }

    componentDidMount()
    {
        RouterUtils.pushRouter('PageXchsHandle', this.props.navigation.state.key);
        this.listener1 = DeviceEventEmitter.addListener('postLocation', (events) => this.postLocation(events));
    }

    componentWillUnmount()
    {
        RouterUtils.popRouter('PageXchsHandle', this.props.navigation.state.key);
        this.listener1.remove();
    }

    showLongPressDelPicModal(item)
    {
        this.setState({
            longPressDelPicItem: item,
            longPressDelPicModal: true
        })
    }

    longPressDelPic()
    {
        var index = this.state.uploadPics.indexOf(this.state.longPressDelPicItem);
        if (index > -1)
        {
            this.state.uploadPics.splice(index, 1);
        }
        this.setState({
            uploadPics: this.state.uploadPics,
            longPressDelPicModal: false
        })
    }

    showLongPressDelVoiceModal()
    {
        this.setState({
            longPressDelVoiceModal: true
        })
    }

    longPressDelVoice()
    {
        this.setState({
            longPressDelVoiceModal: false,
            voiceName: '请录音(非必填)',
            voiceUrl: '',
        })
    }

    toStringPicsUrl()
    {
        var pics = '';
        for (var i = 0; i < this.state.uploadPics.length; i++)
        {
            pics = pics + this.state.uploadPics[i].url + ',';
        }
        pics = pics.substr(0, pics.lastIndexOf(','))
        return pics;
    }

    postLocation(event)
    {
        var data = JSON.parse(event);
        this.setState({
            geoAddress: data.address,
            geoLocation: data.geolocation.lng + ',' + data.geolocation.lat
        })
    }

    showBottomItem()
    {
        this.SimpleItemsDialog.show();
    }

    handle()
    {
        try
        {
            var that = this;
            RuleUtils.checkUploadPics(this.state.uploadPics);
            RuleUtils.checkLocation(this.state.geoAddress);
            RuleUtils.checkEmpty(this.state.questionDesc, '请输入核实描述');
            RuleUtils.checkUnSelectResult(this.state.result, '请选择核实结果');
            this.state.caseDetail.flow.flag = 'ok';
            this.state.caseDetail.retVerify = this.state.result == '属实' ? '2' : '1';
            this.state.caseDetail.flow.comment = this.state.questionDesc;
            this.state.caseDetail.hsGeo = this.state.geoLocation;
            this.state.caseDetail.hsGeoDescript = this.state.geoAddress;
            this.state.caseDetail.picVerify = this.toStringPicsUrl();
            // this.state.caseDetail.hsGeo = "108.870581,34.208749";
            // this.state.caseDetail.hsGeoDescript = '科技七路';
            StorageUtils.get('session').then((session) =>
            {
                if (session != '' && session != null)
                {
                    HttpUtils.postJsonWithRaw(Constant.xchsHandle, session, JSON.stringify(this.state.caseDetail), function (resultcode, data)
                    {
                        ToastUtils.toastShortBottom('核实处理成功')
                        DeviceEventEmitter.emit('xchsOnRefresh', 'param');
                        DeviceEventEmitter.emit('homeReload', 'param');
                        that.props.navigation.goBack(RouterUtils.array[2].pageKey);
                    }, function (resultcode, reason)
                    {
                        ToastUtils.toastShortBottom('错误码:' + resultcode + ',错误原因:' + reason);
                    });
                }
            });
        }
        catch (error)
        {
            ToastUtils.toastShortBottom(error);
        }
    }

    showBottomItem()
    {
        this.SimpleItemsDialog.show();
    }

    jumpLocation()
    {
        this.props.navigation.navigate('WebPage', {'title': '当前位置', 'url': Constant.mapServer +'?type=daka&isShow=true&lng=' + this.state.caseDetail.geo.split(',')[0] + '&lat=' + this.state.caseDetail.geo.split(',')[1]})
    }

    jumpPhoto()
    {
        if (this.state.uploadPics.length >= 3)
        {
            ToastUtils.toastShortCenter('最多上传三张照片')
            return;
        }
        ImagePicker.showImagePicker(options, (response) =>
        {
            if (response.didCancel)
            {
                console.log('User cancelled image picker');
            } else if (response.error)
            {
                console.log('ImagePicker Error: ', response.error);
            } else if (response.customButton)
            {
                console.log('User tapped custom button: ', response.customButton);
            } else
            {
                var that = this;
                HttpUtils.uploadPic(Constant.uploadInspectImg, response.uri, function (resultcode, data)
                {
                    ToastUtils.toastShortBottom('上传图片成功');
                    var imgUrl = {url: data.link.toString()};
                    that.state.uploadPics.push(imgUrl);
                    that.setState({
                        uploadPics: that.state.uploadPics
                    })
                }, function (resultcode, reason)
                {
                    ToastUtils.toastShortBottom('错误码:' + resultcode + ',错误原因:' + reason);
                });
            }
        });
    }

    /**
     * AudioRecorder.prepareRecordingAtPath(path,option)
     * 录制路径
     * path 路径
     * option 参数
     */
    prepareRecordingPath = (path) =>
    {
        const option = {
            SampleRate: 44100.0, //采样率
            Channels: 2, //通道
            AudioQuality: 'High', //音质
            AudioEncoding: 'aac', //音频编码
            OutputFormat: 'mp3', //输出格式
            MeteringEnabled: false, //是否计量
            MeasurementMode: false, //测量模式
            AudioEncodingBitRate: 32000, //音频编码比特率
            IncludeBase64: true, //是否是base64格式
            AudioSource: 0, //音频源
        }
        AudioRecorder.prepareRecordingAtPath(path, option)
    }

    jumpVoicePlay(playUrl)
    {
        if (!playUrl.endsWith('.mp3'))
        {
            ToastUtils.toastShortCenter('音频格式有误');
            return;
        }
        ToastUtils.toastShortCenter('录音开始播放')
        console.log('playUrl:' + playUrl)
        let whoosh = new Sound(playUrl, '', err =>
        {
            if (err)
            {
                return console.log(err)
            }
            whoosh.play(success =>
            {
                if (success)
                {
                    ToastUtils.toastShortCenter('录音播放结束')
                } else
                {
                    ToastUtils.toastShortCenter('录音播放失败')
                }
            })
        })
    }

    jumpVoiceRecord()
    {
        var that = this;
        AudioRecorder.requestAuthorization()
            .then(isAuthor =>
            {
                console.log('是否授权: ' + isAuthor)
                if (!isAuthor)
                {
                    return ToastUtils.toastShortCenter('请前往设置开启录音权限')
                } else
                {
                    this.setState({
                        voiceInputModal: true
                    })
                }
                this.setState({hasPermission: isAuthor})
                console.log('录音路径: ' + this.state.audioPath)
                that.prepareRecordingPath(this.state.audioPath);
                // 录音进展
                AudioRecorder.onProgress = (data) =>
                {
                    that.setState({currentTime: Math.floor(data.currentTime)});
                };
                // 完成录音
                AudioRecorder.onFinished = (data) =>
                {
                    // data 返回需要上传到后台的录音数据
                    console.log(this.state.currentTime)
                    console.log(JSON.stringify(data))
                };
            })
    }

    startVoiceRecodeInput = async () =>
    {
        // 请求授权
        if (!this.state.hasPermission)
        {
            return ToastUtils.toastShortCenter('没有授权')
        }
        if (this.state.recording)
        {
            return ToastUtils.toastShortCenter('正在录音中...')
        }
        if (this.state.stop)
        {
            this.prepareRecordingPath(this.state.audioPath)
        }
        this.setState({recording: true, pause: false})
        try
        {
            await AudioRecorder.startRecording()
        }
        catch (err)
        {
            console.log(err)
        }
    }

    stopVoiceRecodeInput = async () =>
    {
        this.setState({voiceInputModal: false, stop: true, recording: false, paused: false, currentTime: '0'});
        if (this.state.currentTime == 0)
        {
            ToastUtils.toastShortCenter('请先录音');
            return;
        }
        try
        {
            const filePath = await AudioRecorder.stopRecording();
            var that = this;
            HttpUtils.uploadAudio(Constant.uploadVerifyAudio, 'file://' + filePath, function (resultcode, data)
            {
                console.log('data:' + data);
                ToastUtils.toastShortBottom('上传录音成功');
                that.setState({
                    voiceUrl: data.link.toString(),
                    voiceName: '已录音'
                })
                that.state.caseDetail.audioVerify = data.link.toString();
            }, function (resultcode, reason)
            {
                ToastUtils.toastShortBottom('错误码:' + resultcode + ',错误原因:' + reason);
            });
        }
        catch (error)
        {
            console.error(error);
        }
    }

    renderVoiceRecord()
    {
        if (this.state.voiceName == '已录音')
        {
            return (
                <TouchableOpacity activeOpacity={0.8} onPress={() => this.jumpVoicePlay(this.state.voiceUrl)} onLongPress={() => this.showLongPressDelVoiceModal()} style={{marginLeft: 8, marginRight: 12, width: 100, paddingLeft: 8, paddingRight: 8, paddingTop: 4, paddingBottom: 4, borderRadius: 4, backgroundColor: '#E9EDF0', flexDirection: 'row', alignItems: 'center'}}>
                    <Image resizeMode={Image.resizeMode.stretch} style={{width: 16, height: 15}} source={require('../img/voice_record.png')}/>
                    <Text style={{marginLeft: 8, fontSize: ScreenUtils.Font_12, color: ColorUtils.black}}>录音</Text>
                </TouchableOpacity>
            )
        } else
        {
            return (
                <Text style={{marginRight: 16, fontSize: ScreenUtils.Font_14, color: ColorUtils.black}}>{this.state.voiceName}</Text>
            )
        }
    }

    renderUploadPics()
    {
        let allData = [];
        for (let i = 0; i < this.state.uploadPics.length; i++)
        {
            let item = this.state.uploadPics[i];
            allData.push(
                <TouchableWithoutFeedback key={item.url} onLongPress={() =>
                {
                    this.showLongPressDelPicModal(item)
                }}>
                    <Image style={{width: 80, height: 80, borderColor: ColorUtils.line, borderWidth: 1, borderRadius: 10, marginRight: 8,}} source={{uri: item.url}}/>
                </TouchableWithoutFeedback>
            );
        }
        allData.push(
            <TouchableOpacity activeOpacity={0.8} onPress={() => this.jumpPhoto()} key={-1} style={{flexDirection: 'row', justifyContent: 'center', alignItems: 'center', borderStyle: 'dashed', borderColor: ColorUtils.line, borderWidth: 1, borderRadius: 10, width: 80, height: 80}}>
                <Image style={{width: 16, height: 16}} source={require('../img/img_add.png')}/>
            </TouchableOpacity>
        );
        return allData;
    }

    render()
    {
        return (
            <View style={styles.container}>
                <View style={{justifyContent: 'center', alignItems: 'center', paddingLeft: 16, paddingRight: 16}}>
                    <TouchableOpacity activeOpacity={0.8} onPress={() => this.jumpLocation()} style={{flexDirection: 'row', alignItems: 'center', height: 50, paddingTop: 8, paddingBottom: 8, borderBottomWidth: 1, borderBottomColor: ColorUtils.line}}>
                        <Text style={{flex: 1, fontSize: ScreenUtils.Font_14, color: ColorUtils.black}}>打卡地点</Text>
                        <Text numberOfLines={2} style={{textAlign: 'right', width: 220, marginRight: 16, fontSize: ScreenUtils.Font_14, color: ColorUtils.black}}>{this.state.geoAddress}</Text>
                        <View style={{width: 14, justifyContent: 'center', alignItems: 'center'}}>
                            <Image style={{width: 14, height: 18}} source={require('../img/map_location.png')}/>
                        </View>
                    </TouchableOpacity>
                    <TouchableOpacity activeOpacity={0.8} onPress={() => this.showBottomItem()} style={{flexDirection: 'row', alignItems: 'center', height: 50, paddingTop: 8, paddingBottom: 8, borderBottomWidth: 1, borderBottomColor: ColorUtils.line}}>
                        <Text style={{flex: 1, fontSize: ScreenUtils.Font_14, color: ColorUtils.black}}>核实结果</Text>
                        <Text style={{marginRight: 16, fontSize: ScreenUtils.Font_14, color: ColorUtils.black}}>{this.state.result}</Text>
                        <Image style={{width: 9, height: 16}} source={require('../img/arrowright.png')}/>
                    </TouchableOpacity>
                    <TouchableOpacity activeOpacity={0.8} onPress={() => this.jumpVoiceRecord()} style={{flexDirection: 'row', alignItems: 'center', height: 50, paddingTop: 8, paddingBottom: 8, borderBottomWidth: 1, borderBottomColor: ColorUtils.line}}>
                        <Text style={{flex: 1, fontSize: ScreenUtils.Font_14, color: ColorUtils.black}}>核实录音</Text>
                        {this.renderVoiceRecord()}
                        <View style={{width: 14, justifyContent: 'center', alignItems: 'center'}}>
                            <Image style={{width: 13, height: 18}} source={require('../img/voice_input.png')}/>
                        </View>
                    </TouchableOpacity>
                    <View style={{flexDirection: 'row', height: 120, paddingTop: 8, paddingBottom: 8, borderBottomWidth: 1, borderBottomColor: ColorUtils.line}}>
                        <View style={{width: 80, height: 50, flexDirection: 'row', alignItems: 'center',}}>
                            <Text style={{fontSize: ScreenUtils.Font_14, color: ColorUtils.black}}>案件照片</Text>
                        </View>
                        <ScrollView horizontal={true} showsHorizontalScrollIndicator={false}>
                            <View style={{width: ScreenUtils.width - 112, flex: 1, flexDirection: 'row', justifyContent: 'flex-end', alignItems: 'center',}}>
                                {this.renderUploadPics()}
                            </View>
                        </ScrollView>
                    </View>
                    <View style={{flexDirection: 'row', height: 150, paddingTop: 8, paddingBottom: 8}}>
                        <View style={{width: 80, height: 50, flexDirection: 'row', alignItems: 'center',}}>
                            <Text style={{fontSize: ScreenUtils.Font_14, color: ColorUtils.black}}>核实描述</Text>
                        </View>
                        <View style={{flex: 1, borderColor: ColorUtils.line, borderWidth: 1, borderRadius: 10,}}>
                            <TextInput value={this.state.questionDesc} underlineColorAndroid='transparent'
                                       keyboardType={'default'} // 默认键盘类型
                                       autoCapitalize='none' // 取消首字母大写
                                       placeholder='请输入核实描述'
                                       placeholderTextColor={ColorUtils.gray}
                                       multiline={true}
                                       onChangeText={(text) => this.setState({questionDesc: text})}
                                       style={{fontSize: ScreenUtils.Font_12, color: ColorUtils.black, width: "100%", height: "100%", textAlignVertical: 'top'}}/>
                        </View>
                    </View>
                </View>

                <View style={{margin: 32}}>
                    <TouchableOpacity activeOpacity={0.8} onPress={() => this.handle()}>
                        <View style={{justifyContent: 'center', alignItems: 'center', height: 44, padding: 4, borderRadius: 6, backgroundColor: ColorUtils.blue}}>
                            <Text style={{color: ColorUtils.white, fontSize: ScreenUtils.Font_14}}>
                                提交
                            </Text>
                        </View>
                    </TouchableOpacity>
                </View>
                <Modal style={styles.container}
                       transparent={true}
                       visible={this.state.longPressDelPicModal}
                       onRequestClose={() =>
                       {
                           this.setState({longPressDelPicModal: false});
                       }}>
                    <TouchableWithoutFeedback style={{flex: 1, backgroundColor: 'rgba(0, 0, 0, 0.5)',}} onPress={() =>
                    {
                        this.setState({longPressDelPicModal: false})
                    }}>
                        <View style={{flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'rgba(0, 0, 0, 0.6)'}}>
                            <View style={{borderRadius: 10, alignItems: 'center', backgroundColor: '#fff', width: 270, height: 200}}>
                                <View style={{backgroundColor: '#F4F4F4', width: 270, height: 40, borderRadius: 10, flexDirection: 'column', justifyContent: 'center', alignItems: 'center'}}>
                                    <Text style={{fontSize: 16, color: '#333333', marginLeft: 25, marginRight: 25}}>提示</Text>
                                </View>
                                <View style={{width: 270, height: 100, justifyContent: 'center', alignItems: 'center', padding: 16}}>
                                    <Image resizeMode={Image.resizeMode.stretch} style={{width: 50, height: 50}} source={require('../img/del_icon_tip.png')}/>
                                    <Text style={{fontSize: ScreenUtils.Font_14, color: ColorUtils.black, marginTop: 12}}>确定删除照片吗？</Text>
                                </View>
                                <View style={{flex: 1, width: 270, height: 50, flexDirection: 'row', borderTopWidth: 1, position: "absolute", bottom: 0, borderTopColor: '#cccccc', alignItems: 'center'}}>
                                    <TouchableOpacity style={{flex: 1, justifyContent: 'center', alignItems: 'center', height: 44, borderRightColor: '#cccccc'}} onPress={() =>
                                    {
                                        this.setState({longPressDelPicModal: false})
                                    }}>
                                        <Text style={{marginTop: 5, textAlign: 'center', fontSize: 16, marginBottom: 10, color: ColorUtils.blue}}>取消</Text>
                                    </TouchableOpacity>
                                    <TouchableOpacity style={{flex: 1, justifyContent: 'center', alignItems: 'center', height: 44, borderLeftColor: '#cccccc', borderLeftWidth: 1}} onPress={() =>
                                    {
                                        this.longPressDelPic();
                                    }}>
                                        <Text style={{marginTop: 5, textAlign: 'center', fontSize: 16, marginBottom: 10, color: ColorUtils.blue}}>确定</Text>
                                    </TouchableOpacity>
                                </View>
                            </View>
                        </View>
                    </TouchableWithoutFeedback>
                </Modal>
                <Modal style={styles.container}
                       transparent={true}
                       animationType="slide"
                       visible={this.state.voiceInputModal}
                       onRequestClose={() =>
                       {
                           this.setState({voiceInputModal: false});
                       }}>
                    <TouchableWithoutFeedback style={{flex: 1, backgroundColor: 'rgba(0, 0, 0, 0.5)',}} onPress={() =>
                    {
                        // this.setState({voiceInputModal: false})
                    }}>
                        <View style={{flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'rgba(0, 0, 0, 0.5)'}}>
                            <View style={{borderWidth: 1, borderColor: '#D5D5D5', borderRadius: 10, alignItems: 'center', backgroundColor: '#fff', width: 270, height: 200}}>
                                <View style={{backgroundColor: '#F4F4F4', width: 270, height: 40, borderRadius: 10, flexDirection: 'column', justifyContent: 'center', alignItems: 'center'}}>
                                    <Text style={{fontSize: 16, color: '#333333', marginLeft: 25, marginRight: 25}}>提示</Text>
                                </View>
                                <View style={{width: 270, height: 100, justifyContent: 'center', alignItems: 'center', padding: 16}}>
                                    <Image resizeMode={Image.resizeMode.stretch} style={{width: 50, height: 50}} source={require('../img/voice_record_input.png')}/>
                                    <Text style={{fontSize: ScreenUtils.Font_14, color: ColorUtils.black, marginTop: 12}}>录音时长: {this.state.currentTime}s</Text>
                                </View>
                                <View style={{flex: 1, width: 270, height: 50, flexDirection: 'row', borderTopWidth: 1, position: "absolute", bottom: 0, borderTopColor: '#cccccc', alignItems: 'center'}}>
                                    <TouchableOpacity style={{flex: 1, justifyContent: 'center', alignItems: 'center', height: 44, borderRightColor: '#cccccc'}} onPress={() =>
                                    {
                                        this.stopVoiceRecodeInput();
                                    }}>
                                        <Text style={{marginTop: 5, textAlign: 'center', fontSize: 16, marginBottom: 10, color: ColorUtils.blue}}>停止录音</Text>
                                    </TouchableOpacity>
                                    <TouchableOpacity style={{flex: 1, justifyContent: 'center', alignItems: 'center', height: 44, borderLeftColor: '#cccccc', borderLeftWidth: 1}} onPress={() =>
                                    {
                                        this.startVoiceRecodeInput();
                                    }}>
                                        <Text style={{marginTop: 5, textAlign: 'center', fontSize: 16, marginBottom: 10, color: ColorUtils.blue}}>开始录音</Text>
                                    </TouchableOpacity>
                                </View>
                            </View>
                        </View>
                    </TouchableWithoutFeedback>
                </Modal>
                <Modal style={styles.container}
                       transparent={true}
                       visible={this.state.longPressDelVoiceModal}
                       onRequestClose={() =>
                       {
                           this.setState({longPressDelVoiceModal: false});
                       }}>
                    <TouchableWithoutFeedback style={{flex: 1, backgroundColor: 'rgba(0, 0, 0, 0.5)',}} onPress={() =>
                    {
                        this.setState({longPressDelVoiceModal: false})
                    }}>
                        <View style={{flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'rgba(0, 0, 0, 0.6)'}}>
                            <View style={{borderRadius: 10, alignItems: 'center', backgroundColor: '#fff', width: 270, height: 200}}>
                                <View style={{backgroundColor: '#F4F4F4', width: 270, height: 40, borderRadius: 10, flexDirection: 'column', justifyContent: 'center', alignItems: 'center'}}>
                                    <Text style={{fontSize: 16, color: '#333333', marginLeft: 25, marginRight: 25}}>提示</Text>
                                </View>
                                <View style={{width: 270, height: 100, justifyContent: 'center', alignItems: 'center', padding: 16}}>
                                    <Image resizeMode={Image.resizeMode.stretch} style={{width: 50, height: 50}} source={require('../img/del_icon_tip.png')}/>
                                    <Text style={{fontSize: ScreenUtils.Font_14, color: ColorUtils.black, marginTop: 12}}>确定删除录音吗？</Text>
                                </View>
                                <View style={{flex: 1, width: 270, height: 50, flexDirection: 'row', borderTopWidth: 1, position: "absolute", bottom: 0, borderTopColor: '#cccccc', alignItems: 'center'}}>
                                    <TouchableOpacity style={{flex: 1, justifyContent: 'center', alignItems: 'center', height: 44, borderRightColor: '#cccccc'}} onPress={() =>
                                    {
                                        this.setState({longPressDelVoiceModal: false})
                                    }}>
                                        <Text style={{marginTop: 5, textAlign: 'center', fontSize: 16, marginBottom: 10, color: ColorUtils.blue}}>取消</Text>
                                    </TouchableOpacity>
                                    <TouchableOpacity style={{flex: 1, justifyContent: 'center', alignItems: 'center', height: 44, borderLeftColor: '#cccccc', borderLeftWidth: 1}} onPress={() =>
                                    {
                                        this.longPressDelVoice();
                                    }}>
                                        <Text style={{marginTop: 5, textAlign: 'center', fontSize: 16, marginBottom: 10, color: ColorUtils.blue}}>确定</Text>
                                    </TouchableOpacity>
                                </View>
                            </View>
                        </View>
                    </TouchableWithoutFeedback>
                </Modal>
                <SimpleItemsBottom
                    items={[{value: '属实'}, {value: '不属实'}]}
                    itemKey='value'
                    ref={ref => this.SimpleItemsDialog = ref}
                    onPress={(pos) =>
                    {
                        if (pos == 0)
                        {
                            this.setState({
                                result: '属实'
                            })
                        } else
                        {
                            this.setState({
                                result: '不属实'
                            })
                        }
                    }}/>
            </View>
        );
    }

}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: ColorUtils.white,
    },
    tabBarUnderlineStyle: {
        height: 2,
        minWidth: Math.floor(ScreenUtils.width * 0.8 / 8),
        backgroundColor: ColorUtils.blue,
    },
    tabBarTextStyle: {
        fontSize: ScreenUtils.Font_14,
        fontWeight: 'normal'
    }
});


